<?PHP

require_once("dbconnect.php");
require_once("../articles/classes/article.php");

include("../articles/fckeditor.php");

$temp_article_id=0;

if($_GET['article_id']){

	$temp_article_id = $_GET['article_id'];

} elseif ($_POST['article_id']){

	$temp_article_id = $_POST['article_id'];

}

$articleObj=new article($temp_article_id);


if($_POST['Submit_x'] != ""){

	if($_POST['actio']=="ADD"){

		$articleObj->article_name=$_POST['article_name'];

		$articleObj->content=$_POST['content'];

		$mesg  = $articleObj->add_article();

		if($mesg=="Y"){

			$mesg1=="Y";

			$mesg="Article has been added successfully.";

		}

	}else{

		$articleObj->article_name=$_POST['article_name'];

		$articleObj->content=$_POST['content'];

		$mesg  = $articleObj->edit_article();

	}

} else {

	$articles = $articleObj->get_article_by_id();

	if($row=mysql_fetch_array($articles)){

		$p_name = stripslashes($row['article_name']);

		$p_content = stripslashes($row['content']);

	}

}

?>
<?php require_once('include/header.php'); ?>
      <div id="middle_container_for_innerpage">
      <div id="innerpage_top_image"><img src="images/images/innerpage_top_corner_820x5.jpg"  height="5" /></div> 
      <div id="middle_inner_container">
      <?php require_once('include/left_side_menu.php'); ?>
	          
        <div id="inner_page_middle_data">
		<table width="100%" border="1" align="center" cellpadding="0" cellspacing="0" bordercolor="#33CCFF">
  <tr>
    
    <td valign="top" ><table width="100%" border="0" cellspacing="0" cellpadding="0" align="center">

	<tr>

		<td height="50"></td>
	</tr>

	<tr>

		<td align="center" class="header"><?if($temp_article_id){?>Modify<?}else{?>Add<?}?> Article</td>
	</tr>

	<tr>

		<td height="10"></td>
	</tr>

	<tr>

		<td>

		<table width="100%" border="0" align="center" cellpadding="5" cellspacing="0" class="main-table">

		<tr>

			<td colspan="2" height="10"></td>
		</tr>

		<? if($mesg){ ?>

		<tr>

			<td colspan="2" class="mesg" height="10"><strong><?=$mesg?></strong></td>
		</tr>

		<? } else {

		if($mesg1!="Y"){

		?>

	    <FORM name="frm" method="POST" action="mod_articles.php" onSubmit="javascript:return validatePage(this)">



		<tr>

			<td width="15%" class="login-text">Article Name : </td>

			<td width="85%"><input class="textbox"  name="article_name" type="text" size="50" maxlength="255" onKeyPress="return ValidateAlphaNumeric(this,event);" value="<?=$p_name?>"></td>
		</tr>

		<tr>

			<td colspan="2" height="5"></td>
		</tr>

		<tr>

			<td colspan="2" valign="top" class="login-text">Article Contents :<br /> 

				<!-- <textarea name="content" rows="30" cols="80"><?=$p_content?></textarea> //-->

				<?php

					$oFCKeditor = new FCKeditor;

					$oFCKeditor->BasePath = '' ;

					$oFCKeditor->ToolbarSet = 'Basic';

					$oFCKeditor->Value = $p_content;

					$oFCKeditor->CreateFCKeditor('content', '560', '500' );

				?>			</td>
			</tr>

		<tr>

			<td colspan="2" height="5"></td>
		</tr>

		<tr>

			<td></td>

			<td>

			  <input type="image" name="Submit" value="Y" src="../images/submit.gif" border="0">

			  <?if($temp_article_id){?>

			  <input name="actio" type="hidden" value="MODIFY">

			  <?}else{?>

			  <input name="actio" type="hidden" value="ADD">

			  <?}?>

			  <input class="text-field"  name="article_id" type="hidden" value="<?=$temp_article_id?>">

			  <input class="text-field"  name="action" type="hidden" value="Modify">			</td>
		</tr>
		</form>

		<? }} ?>

		<tr>

			<td colspan="2" height="10"></td>
		</tr>
		</table>		</td>
	</tr>

	</table>    </td>
  </tr>
</table>
		</div>
      </div> 
      <div id="corner_container_bottom_for_innerpage"><img src="images/images/innerpage_bottom_corner_820x10.jpg"  height="10" /></div>
    </div> 
      <!-- middle_container ends -->
    
    <div id="bottom_container">
<?php require_once('include/footer.php'); ?>
